package com.runen.wnhz.runen.ui.adapter.puadapter;

import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.runen.wnhz.runen.R;
import com.runen.wnhz.runen.data.entity.ReceivingAddressEntity;

/**
 * 描述：
 * 作者： 天天童话丶
 * 时间： 2018/5/31.
 */

public class ReceivingAddressAdapter extends BaseQuickAdapter<ReceivingAddressEntity, BaseViewHolder> {

    public ReceivingAddressAdapter() {
        super(R.layout.receiving_address_item, null);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final ReceivingAddressEntity item) {
        helper.setText(R.id.tv_user_name, item.getConsignee());
        helper.setText(R.id.tv_user_address, item.getProvince() + item.getCity() + item.getCounty() + item.getPlace());
        helper.setText(R.id.tv_user_phone, item.getTelephone());
        switch (item.getMoren()){
            case "1":   //不是
                Drawable drawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_rb_unsele);
                ((TextView)helper.getView(R.id.tv_default)).setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
                break;
            case "2":    //是
                Drawable drawable1 = ContextCompat.getDrawable(mContext, R.mipmap.icon_rb_sele);
                ((TextView)helper.getView(R.id.tv_default)).setCompoundDrawablesWithIntrinsicBounds(drawable1, null, null, null);
                break;
        }

        helper.addOnClickListener(R.id.tv_edit);
        helper.addOnClickListener(R.id.tv_delete);
        helper.addOnClickListener(R.id.relative_receivePersonInfo);
    }
}